#include "laurin-module-handler.h"



LaurinModuleHandler::LaurinModuleHandler()
{
	_modules = 0;
	_running = false;
	_error = false;
}


LaurinModuleHandler::~LaurinModuleHandler(){}


void LaurinModuleHandler::moduleWorkingComplete(bool error)
{
	bool stop = false;

	_mutex.lock();
	_modules++;
	stop = _modules == _modules_count;
	_mutex.unlock();

	if(stop)
	{
		if(!_error)
			_error = error;
		_running = false;
	}
}


void LaurinModuleHandler::setError(Glib::ustring errorMessage)
{
	_errmess = errorMessage;
}


Glib::ustring LaurinModuleHandler::getErrorMessage() const
{
	return _errmess;
}


bool LaurinModuleHandler::isErrorRaised() const
{
	return _error;
}


void LaurinModuleHandler::startHandler(int count)
{
	_modules = 0;
	_running = true;
	_error = false;
	_modules_count = count;
}


bool LaurinModuleHandler::isRunning() const
{
	return _running;
}
